package com.bgs.controller;


import com.bgs.common.R;
import com.bgs.service.AliOssService;
import com.bgs.service.PictureService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 图片表 前端控制器
 * </p>
 *
 * @author Asia
 * @since 2021-09-14
 */
@RestController
@RequestMapping("/bgs/picture")
public class PictureController {
    @Autowired
    private AliOssService aliOssService;

    @Autowired
    private PictureService pictureService;

    @ApiOperation("处理阿里OSS图片")
    @PostMapping("/handelPic")
    public String handelPic(MultipartFile file) {
        return aliOssService.upload(file);
    }

    /**
     * 查询商品对应的图片
     * @param id
     * @return
     */
    @GetMapping("/fourQueryImg")
    public R fourQueryImg(int id){
        return pictureService.fourQueryImg(id);
    }
}

